package top.huhuiyu.springboot3.p2301.task;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import top.huhuiyu.springboot3.p2301.service.api.NewsDataService;

@EnableScheduling
@Component
@RequiredArgsConstructor
@Slf4j
public class AutoDataTask {
    private final NewsDataService newsDataService;

    @Scheduled(initialDelay = 30000 * 1000, fixedDelay = 60 * 60 * 1000)
    public void makeNewsData() {
        log.debug("开始自动生成新闻数据");
        int count = newsDataService.makeNewsData();
        log.debug("生成新闻数据完成，生成数量：{}", count);
    }
}
